<?php
/**
 * @fileoverview    feed页翻页接口
 * @author          xinhua
 * @date            Feb  02 11:31:49 CST 2012
 * @copyright       sina meila
 */

include_once '../../__global.php';
include_once './scroll_public.php';
class aj_getPubFeed extends scroll_public{

    public function main(){

        $nickname=$this->__visitor['nickname'];

        //获得我关注的人的uid
        $oFollow = new ml_model_dbFollow();
        $oFollow->getList($this->__visitor['uid'],0,200);
        $rs = $oFollow->get_data();
        
        
        $uids = array();
        if(is_array($rs)) {
            foreach($rs as $k => $v) {
                $uids[] = $v['follow_uid'];
            }
        }
        
        //    找出feed
        $oFeed = new ml_model_dbPublicFeed();
        $block = ($this->_pagenum - 1) * 3 + $this->_offset;
        $rs = $oFeed->getListByUids($uids, $block);
        
        if(!$rs)
            $this->redirect(ML_PAGE_SYSTEM_BUSY);
            
        $feed = $oFeed->get_data();
        foreach ($feed as $k => $v) {
            if(!empty($v['userfeed_rid']))
                $feed[$k]['rid'] = $v['userfeed_rid'];
            else{
                $feed[$k]['rid'] = 0;
            }
            if(!in_array($v['uid'], $auid))
                $auid[] = $v['uid'];
        }
        
        $htmlModel=new ml_biz_feed_user();        
        $Acontent = $htmlModel->output($feed, $this->__visitor['uid']);
        $finnal['content']=$Acontent;
        
        
        
        $total=$oFeed->getCntByUids($uids);
         
         
        $htmlModel=new ml_biz_feed_user();
        $auid[]= $this->__visitor['uid'];
        $data=$htmlModel->output($feed, $this->__visitor['uid']);

        $last=count($data) < ML_FEED_PAGESIZE?true:false;
        $finnal['lastSegment']=$last;
        $finnal['items']=$data;

        $this->api_output(ML_RCODE_SUCC,$finnal);

    }
}
new aj_getPubFeed();
?>